<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
<script src="http://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>	
<div id="root">
	<p>
		<router-link to='/a'>/a</router-link>
		<router-link :to="{name:'foo'}">/foo</router-link>
	</p>
	<div>
		<router-view></router-view>
	</div>
</div>
<script>
	//重定向也是通过 routes 配置来完成，下面例子是从 /a 重定向到 /b
const A = {template:`<div>这是A组件</div>`};
const Foo = {template:`<div>这是B组件</div>`};
const router = new VueRouter({
  routes: [
    { path: '/a', redirect: {name:'foo'}, component: Foo },
    { path: '/foo', name: 'foo', component: A }
  ]
})
const vm = new Vue({
	el : '#root',
	router,
	data : {}
})
</script>
</body>
</html>